﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace P_PersonalDetails
{
    public partial class GenderPicker : UserControl
    {
        public GenderPicker()
        {
            InitializeComponent();
        }



        public bool? IsMale
        {
            get { return (bool?)GetValue(IsMaleProperty); }
            set { SetValue(IsMaleProperty, value); }
        }

        // Using a DependencyProperty as the backing store for IsMale.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty IsMaleProperty =
            DependencyProperty.Register("IsMale", typeof(bool?), typeof(GenderPicker), new PropertyMetadata(null, (DO, DE) => 
            {
                if (DE.OldValue != DE.NewValue)
                {
                    bool? NewValue = (bool?)DE.NewValue;
                    GenderPicker GP = (GenderPicker)DO;
                    if (NewValue.HasValue)
                    {
                        if (NewValue.Value)
                        {
                        GP.MTB.IsChecked = true;
                        GP.FTB.IsChecked = false;
                        }
                        else
                        {
                            GP.MTB.IsChecked = false;
                            GP.FTB.IsChecked = true;
                        }
                    }
                    else
                    {
                        GP.MTB.IsChecked = false;
                        GP.FTB.IsChecked = false;
                    }                    
                }
            }));

        private void MaleChecked(object sender, RoutedEventArgs e)
        {
            IsMale = true;
        }

        private void FemaleChecked(object sender, RoutedEventArgs e)
        {
            IsMale = false;
        }

        private void MaleUnchecked(object sender, RoutedEventArgs e)
        {
            if (IsMale == true)
            {
                IsMale = null;
            }
        }

        private void FemaleUnchecked(object sender, RoutedEventArgs e)
        {
            if (IsMale == false)
            {
                IsMale = null;
            }
        }

        
    }
}
